define([], function () {
    function initialize() {
        var formData = {
            name: ko.observable('World'),
            selectSex: ko.observable({id: '1', value: '男'}),
            selectHobby: ko.observable(),
            selectSwitch: ko.observable(),
            selectRadio: ko.observable(),
            selectRadio1: ko.observable(),
            textArea: ko.observable()
        };

        var vm = {
            button: {
                text: '添加select选项',
                css: 'layui-btn-sm',
                icon: '&#xe60c;',
                fnClick: function () {
                    vm.select.optionList.push({id: '4', value: '其他'});
                }
            },
            label: {
                value: '你好'
            },
            input: {
                value: formData.name
            },
            select: {
                name: 'sex',
                optionList: ko.observableArray([{id: '1', value: '男'}, {id: '2', value: '女'}, {id: '3', value: '保密'}]),
                selectedValue: formData.selectSex
            },
            checkbox: {
                option: {id: '1', value: '写作'},
                checked: true,
                selectedValue: formData.selectHobby
            },
            checkbox2: {
                skin: 'switch',
                options: [{id: '1', value: '开启'}, {id: '-1', value: '关闭'}],
                selectedValue: formData.selectSwitch
            },
            radio: {
                option: {id: '1', value: '男'},
                filter: 'sex',
                checked: true,
                selectedValue: formData.selectRadio
            },
            radio2: {
                option: {id: '2', value: '女'},
                filter: 'sex',
                selectedValue: formData.selectRadio
            },
            radio11: {
                option: {id: '11', value: '男变女'},
                filter: 'sex1',
                checked: true,
                selectedValue: formData.selectRadio1
            },
            radio12: {
                option: {id: '12', value: '女变男'},
                filter: 'sex1',
                selectedValue: formData.selectRadio1
            },
            textarea: {
                placeholder: '请输入',
                value: formData.textArea
            },
            submitButton: {
                text: '提交',
                fnClick: function () {
                    layer.msg(ko.mapping.toJSON(formData));
                }
            }
        };

        return vm;
    }

    return {
        initialize: initialize
    }
});